﻿Public Class FormProductEditor

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If Me.txtProductCode.Text = "" Then
            MsgBox("Please input product code")
            Me.txtProductCode.Focus()
            Exit Sub
        End If
        If Me.txtProductName.Text = "" Then
            MsgBox("Please input product name")
            Me.txtProductName.Focus()
            Exit Sub
        End If 


        'Dim tmp As Decimal
        'Dim result = Decimal.TryParse(Me.txtPrice.Text, tmp)
        'If result = False Then
        '    MsgBox("Plese input correct decimal value")
        '    Me.txtPrice.Focus()
        '    Exit Sub
        'End If

        If Validator.IsDecimal(Me.txtPrice.Text) = False Then
            MsgBox("Plese input correct decimal value")
            Me.txtPrice.Focus()
            Exit Sub
        End If

        If Me.txtPrice.Text <= 0 Or Me.txtPrice.Text >= 100 Then
            MsgBox("Price must be between 0 and 100")
            Me.txtPrice.Focus()
            Exit Sub
        End If


        MsgBox("Save success!")

 

    End Sub

End Class